package com.windgo.controller.wx;

import com.windgo.bean.MarketComment;
import com.windgo.bean.common.BasePageInfo;
import com.windgo.bean.common.BaseRespVo;
import com.windgo.bean.common.CommonData;
import com.windgo.bean.vo.WxCommentCountVo;
import com.windgo.bean.vo.WxCommentListVo;
import com.windgo.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:ZhouXin
 * @Date:2022/10/14 10:23
 * @Description:
 **/
@RestController
@RequestMapping("wx/comment")
public class WxCommentController {
    @Autowired
    CommentService commentService;

    /**
     * 根据valueId显示所有的评论信息
     * @param info
     * @param valueId
     * @param type:0表示商品   1表示专题
     * @return
     */
    @GetMapping("list")
    public BaseRespVo list(BasePageInfo info,Integer valueId,Integer showType,Integer type){
        CommonData<WxCommentListVo> data =commentService.wxList(info,valueId,showType,type);
        return BaseRespVo.ok(data);
    }

    /**
     *根据value和type统计评论数量
     * type=0:商品评论
     * @param valueId
     * @param type
     * @return
     */
    @GetMapping("count")
    public BaseRespVo count(Integer valueId,Byte type){
        WxCommentCountVo data =commentService.count(valueId,type);
        return BaseRespVo.ok(data);
    }

    /**
     * 专题提交的评论
     * @return
     */
    @PostMapping("post")
    public BaseRespVo post(@RequestBody MarketComment marketComment){
        MarketComment data=commentService.wxPost(marketComment);
        return BaseRespVo.ok(data);
    }
}
